package com.shuai.model.converter;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.shuai.model.po.SysOrgan;
import com.shuai.model.vo.SysOrganVo;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * 机构信息转换器
 *
 * @author shuai
 * @since 2022
 */
@Slf4j
public class SysOrganConverter {
    /**
     * Po转换Vo
     * @param source
     * @return
     */
    public static SysOrganVo convertToVoByPo(SysOrgan source) {
        SysOrganVo target = new SysOrganVo();
        BeanUtil.copyProperties(source, target);
        return target;
    }

    /**
     * Po转换Vo
     * @param sources
     * @return
     */
    public static List<SysOrganVo> convertToVoByPo(List<SysOrgan> sources) {
        List<SysOrganVo> newList = CollUtil.newArrayList();
        sources.stream().forEach(item->{
            SysOrganVo target = new SysOrganVo();
            BeanUtil.copyProperties(item, target);
            newList.add(target);
        });
        return newList;
    }
}
